VPATH=src:include:test
CC=gcc
CFLAGS=-Wall -ggdb3 -Iinclude # debug:put -ggdb instead of -O3
LDFLAGS=-L /usr/lib -L/usr/local/lib -Llib -L.
OBJECTS=regist_config.o getinfo.o mylog.o getconfig.o 
LIBNAME=lib/libmylog.so

$(LIBNAME):$(OBJECTS)
	 $(CC) -shared -fPCI $(LDFLAGS) $(LPTHREAD) $^ -o $(LIBNAME)
			-rm -rf *.o
$(OBJECTS):%.o:%.c
			 $(CC) -c $(CFLAGS) $^ -o $@

test:$(LIBNAME) test.c test_multithreads.c
	gcc -lmylog $(LDFLAGS) $(CFLAGS) test/test.c -o test/test.exe
	 gcc -lmylog -lpthread $(LDFLAGS) $(CFLAGS) test/test_multithreads.c -o test/test_multithreads.exe
	 cp $(LIBNAME) test/
install:$(LIBNAME)
		-sudo cp $(LIBNAME) /usr/lib/ 

clean:
	-find . \( -name '*.o' -o -name '*.so' -o -name '*.bak' -o \
	        -name '*.swp' -o -name '*.out' -o -name '*.gch' -o -name '*.*~' -o \
	        -name '*.exe' -o -name 'core.*' -o -name '*.gch' -o -name '*.files' \) \
	       	-type f -execdir rm -f '{}' \; 

.PHONY:clean
